package com.cykj.service.impl;

import com.cykj.mapper.CommentMapper;
import com.cykj.pojo.Comment;
import com.cykj.pojo.TicketsOrder;
import com.cykj.service.CommentService;
import com.cykj.util.PageResult;
import com.cykj.util.PageUtils;
import com.cykj.util.ResponseDto;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;
    @Override
    public ResponseDto getComments(int pageCurr, int pageSize,int foodsId,int scenicId) {
        Page<Object> page = PageHelper.startPage(pageCurr, pageSize);
        List<Comment> comments = commentMapper.getComments(foodsId, scenicId);
        PageInfo<Object> pageInfo = new PageInfo<>(page);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return new ResponseDto(1,"查询成功",pageResult);

    }

    @Override
    public ResponseDto upComment(String userName, String value, String foodsId, int scenicId) {
        int i = commentMapper.upComment(userName, value, foodsId, scenicId);
        return new ResponseDto(1,"评论成功",null);
    }
}
